<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展 
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------

namespace app\admin\model\wddj\evaluation;

use think\Model;


class Evaluation extends Model
{

    

    

    // 表名
    protected $name = 'wddj_order_evaluation';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'satisfaction_status_text',
        'is_anonymity_text'
    ];
    

    
    public function getSatisfactionStatusList()
    {
        return ['1' => __('Satisfaction_status 1'), '2' => __('Satisfaction_status 2')];
    }

    public function getIsAnonymityList()
    {
        return ['1' => __('Is_anonymity 1')];
    }


    public function getSatisfactionStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['satisfaction_status']) ? $data['satisfaction_status'] : '');
        $list = $this->getSatisfactionStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsAnonymityTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_anonymity']) ? $data['is_anonymity'] : '');
        $list = $this->getIsAnonymityList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function agent()
    {
        return $this->belongsTo('app\admin\model\wddj\CertifiedDrivingAgent', 'wechat_id', 'wechat_id', [], 'LEFT')->setEagerlyType(0);
    }


    public function order()
    {
        return $this->belongsTo('app\admin\model\wddj\Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
